package com.baizhi.springmvc.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import sun.plugin2.util.NativeLibLoader;

public class RedisUtil {
    static JedisPool jedisPool=null;
    static {
        JedisPoolConfig jedisPoolConfig=new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(100);
        jedisPool=new JedisPool(jedisPoolConfig,"192.168.135.136");

    }
    public static Jedis getJedis() {
        if (jedisPool != null) {
            Jedis jedis = jedisPool.getResource();
            return jedis;
        }
        throw new RuntimeException("连接池有有问题");
    }

    public static void ClossJedis(Jedis jedis) {
        if (jedis != null) {
            jedis.close();
        }
    }
}
